<template>
    <div>
        <h2>排房页面</h2>
        
        <table>
            <tr>
                <td>姓名</td>
                <td>
                    <input type="text" v-model="data.pfmc">
                </td>
            </tr>
            <tr>
                <td>房号</td>
                <select v-model="data.fhid">
                    <option value=0>请选择</option>
                    <option v-for="m in fhxs" :value="m.fhid">{{ m.fhmc }}</option>
                </select>
            </tr>
                  <tr>
                <td>房型</td>
                <select v-model="data.fxid">
                    <option value=0>请选择</option>
                    <option v-for="m in fxxs" :value="m.fxid">{{ m.fxmc }}</option>
                </select>
            </tr>
             
           
          
             <tr>
                <td></td>
                <td>
                    <input type="button" value="排房" @click="add">
                </td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';

const data=ref({
   "pfid": 0,
  "fhid": 0,
  "fxid": 0,
  "pfmc": ""
})

const add=()=>{

    axios.post("https://localhost:7258/api/pfroom/pfadd",data.value).then(res=>{
      if(res.data>0){

            alert("排房成功");
            location.href="/pfxs"
        } else{
            alert("排房失败");
        }
    })
}
onMounted(()=>{
    xs();
    fhxss();
 })
 const fhxs=ref([{
     "fhid": 2,
    "fhmc": "305",
    "fhbz": "面积很大",
    "fhcjsj": "2025-06-16T16:30:51.8026098",
    "fhnrsj": "2025-06-16T16:30:51.8026063",
    "zt": true
 }])
 const xs=()=>{
    axios.get("https://localhost:7258/api/pfroom/fhxsss").then(res=>{
        fhxs.value=res.data
    })
 }
  const fxxs=ref([{
  "fxid": 1,
    "fxmc": "双人房",
    "fxdx": 200,
    "img": "/pic/2d16c6b7-5af4-4b7b-946c-6dec428987712.webp",
    "rs": "200",
    "jg": "100"
 }])
 const fhxss=()=>{
    axios.get("https://localhost:7258/api/roomfx/fxsx").then(res=>{
        fxxs.value=res.data
    })
 }




</script>

<style scoped>

</style>